package com.durian.base.update.proxy.impl

import android.content.Intent
import com.durian.base.frame.ActivityStack
import com.durian.base.update.XUpdate
import com.durian.base.update.entity.DownloadEntity
import com.durian.base.update.proxy.IUpdateInstaller
import com.durian.base.update.ui.ActivityDefaultInstaller

open class DefaultUpdateInstaller : IUpdateInstaller {
    override fun startInstall(downloadEntity: DownloadEntity) {
        if (ActivityStack.create().isAppVisible){
            val intent = Intent(XUpdate.getContext(),ActivityDefaultInstaller::class.java)
            intent.putExtra("apkFilePath",downloadEntity.apkFile.absolutePath)
            intent.putExtra("force",downloadEntity.versionEntity.forceUpdate)
            XUpdate.getContext().startActivity(intent)
        }
    }
}